package com.monkar.java.dao;

import java.util.List;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.stereotype.Repository;

import com.monkar.java.bean.RequisitoDTO;
import com.monkar.java.constans.QuerysMySQL;
import com.monkar.java.constans.RowMapperConstans;


@Repository
public class RequisitoDAO {
	
	private SimpleJdbcTemplate simpleJdbcTemplate;
    private JdbcTemplate jdbcTemplate;
	private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
	
	@Autowired
	public void init(DataSource dataSource) {
		this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
		this.jdbcTemplate=new JdbcTemplate(dataSource);
		this.namedParameterJdbcTemplate=new NamedParameterJdbcTemplate(dataSource);
	} 
	
	
	
//	ahora si podemos insertar los registros en objetos RequisitoDTO
	@SuppressWarnings("unchecked")
	public List<RequisitoDTO> listaRequisitos(){
		StringBuffer sqlb = new StringBuffer();
		sqlb.append(QuerysMySQL.LISTAR_REQUISITOS);
		sqlb.append(" and rt.idtramite=1 ");
		String sql = sqlb.toString();
		return this.jdbcTemplate.query(sql, new RowMapperConstans.RequisitoMapper());
		
		
	}
	

}
